<template>
	<view class="agepage">
		<u-sticky bgColor="#fff">
			<view style="padding: 20rpx 40rpx">
				<u-search :show-action="true" v-model="queryParams.corpname" actionText="搜索" placeholder="请输入企业名称" :animation="true" :actionStyle="{ color: '#666' }" @clear="getList1s()" @search="getList1s()" @custom="getList1s()"></u-search>
			</view>
		</u-sticky>
		
		<view style="padding: 30rpx">
			<view class="statistics">
			    <view class="num_item">
			      <view class="num_item_label">累计收货</view>
			      <view class="num_item_value">
			        <u-count-to
			          :endVal="creditCount.total"
			          color="#101010"
			          bold
			          separator=","
			          fontSize="18"
			        ></u-count-to>
			      </view>
			    </view>
			    <view class="num_item">
			      <view class="num_item_label">本月收货</view>
			      <view class="num_item_value">
			        <u-count-to
			          :endVal="creditCount.month"
			          color="#101010"
			          bold
			          separator=","
			          fontSize="18"
			        ></u-count-to>
			      </view>
			    </view>
			    <view class="num_item">
			      <view class="num_item_label">今日收货</view>
			      <view class="num_item_value">
			        <u-count-to
			          :endVal="creditCount.today"
			          color="#101010"
			          bold
			          separator=","
			          fontSize="18"
			        ></u-count-to>
			      </view>
			    </view>
			</view>
			
			<view class="listitem" v-for="(item, index) in tableData" :key="index"
				@click="pagelink(item)">
				<view class="tit">{{ item.corpname || '--' }}</view>
				<view class="flex">
					<text>发货编号</text>
					<view class="name">{{ item.deliveryNo || '--' }}</view>
				</view>
				<view class="flex">
					<text>浇筑部位</text>
					<view class="name">{{ item.flowBuildingArea || '--' }}</view>
				</view>
				<view class="flex">
					<text>本车量</text>
					<view class="name">{{ item.thisQuantity || '--' }}</view>
				</view>
				<view class="flex">
					<text>收货时间</text>
					<view class="name">{{ (item.departTime || '--').split(' ')[0] }}</view>
				</view>
				<view class="flex">
					<text>收货人员</text>
					<view class="name">{{ item.receiving || '--' }}</view>
				</view>
			</view>
		
			<view style="padding-top: 50rpx;" v-if="tableData.length==0">
				<u-empty text="暂无数据" :icon="emptyIcon"></u-empty>
			</view>
		</view>
	</view>
</template>

<script setup>
import { ref } from 'vue';
import { onLoad,onReachBottom } from "@dcloudio/uni-app";
import emptyIcon from "@/pagesC/static/images/ndata.png"
import { deliveryList,deliverycount } from '@/api/qss/zxhapi.js'

const sollfunct = ref(0)
const tableData = ref([])
const projectname = ref('')
const creditCount = ref({
  total: 0,
  month: 0,
  today: 0,
});
const queryParams = ref({
	corpname: '',
	projectname: '',
	pageSize: 20,
	pageNum: 1,
})

function pagelink(item){
	uni.navigateTo({
		url: '/pagesC/project/arrangeEdit'
	})
}

function getList1s() {
	queryParams.value.pageNum = 1
	tableData.value = []
	getList()
}

function getList(){
	uni.showLoading({ title: '加载中' })
	deliveryList(queryParams.value).then(res=>{
		console.log(res, '列表')
		if (res.rows) {
			tableData.value.push(...res.rows);
			let total =  res.total || 0
			queryParams.value.pageSize * queryParams.value.pageNum < total ? sollfunct.value = 1 : sollfunct.value = 0
		} else {
			sollfunct.value = 0
		}
	}).finally(()=>{
		uni.hideLoading()
	})
};

function getCont(){
	deliverycount({projectname: projectname.value}).then(res=>{
		console.log(res, '统计')
		if(res.data){
			creditCount.value = res.data.total|| 0
			creditCount.value = res.data.month|| 0
			creditCount.value = res.data.today|| 0
		}
	})
}

onReachBottom(() => {
	if (sollfunct.value == 1) {
		queryParams.value.pageNum++
		getList()
	}
})

onLoad((option)=>{
	projectname.value = option.name
	queryParams.value.projectname = option.name
	getList()
	getCont()
})

</script>

<style lang="less" scoped>
.agepage{
	min-height: 100%;
	background: #f8f8f8;
	.selectbox {
		width: 90px;
		margin-right: 5px;
		padding-right: 10px;
		border-right: 1px solid #ddd;
	
		::v-deep .uni-select {
			border: none !important;
			border-radius: inherit !important;
		}
	
		::v-deep .uni-select__input-placeholder {
			font-size: 26rpx !important;
		}
	
		::v-deep .uni-input-input {
			font-size: 26rpx !important;
		}
	
		::v-deep .u-input {
			background: #f2f2f2 !important;
			padding: 4.5px 8px !important;
		}
	}
	.listitem {
		padding: 30rpx;
		background: #fff;
		border-radius: 16rpx;
		margin-bottom: 30rpx;
		line-height: 1.5;
	
		.tit {
			line-height: 1.6;
			font-size: 36rpx;
			margin-bottom: 10rpx;
			font-weight: bold;
			display: -webkit-box;
			-webkit-box-orient: vertical;
			-webkit-line-clamp: 2;
			word-break: normal;
			word-wrap: break-word;
			overflow: hidden;
		}
	
		.flex {
			display: flex;
			justify-content: space-between;
			font-size: 28rpx;
			line-height: 2;
			align-items: center;
	
			text {
				color: #666;
			}
		}
	}
	.statistics {
	    background-color: #fff;
	    border-radius: 16rpx;
	    padding: 30rpx;
	    display: flex;
	    justify-content: space-between;
	    text-align: center;
		margin-bottom: 30rpx;
	
	    &_item {
	      &_label {
	        white-space: nowrap;
	        text-overflow: ellipsis;
	        overflow: hidden;
	        color: #666666;
	        font-size: 28rpx;
	      }
	
	      &_value {
	        margin-top: 10rpx;
	        font-size: 36rpx;
	        font-weight: bold;
	        white-space: nowrap;
	        text-overflow: ellipsis;
	        overflow: hidden;
	      }
	    }
	}
}
</style>